package form
{
   import flash.events.*;
   import flash.display.*;
   import flash.text.*;
   import flash.geom.*;
   import flash.utils.*;
   import flash.net.*;
   import flash.ui.*;
   // greensock
   //import com.greensock.*;
   //import com.greensock.easing.*;

   /**
    * @author   cjboy1984
    */
   public class PhotoEditor extends MovieClip
   {
      // fla
      public var mcPanel:MovieClip;
      public var btnEdit:MyButton;

      // flag
      public static var PHOTO_POS:Point;
      public static var PHOTO_SCALE:Number;

      /* constructor */
      public function PhotoEditor()
      {
         visible = false;
         tabEnabled = false;
         tabChildren = false;
         focusRect = false;

         stop();

         addEventListener(Event.ADDED_TO_STAGE, onAdd);
         addEventListener(Event.REMOVED_FROM_STAGE, onRemove);
      }

      // ------------------ LINE -------------------

      /**
       * 只有瀏覽照片時會呼叫edit()
       */
      public function edit():void
      {
         visible = true;

         // init flag
         PHOTO_POS = null;
         PHOTO_SCALE = -1;

         MyTween.labelTo(this, 'in');
      }

      /**
       * 再編修，通常是呼叫過closePanel()才會發生
       */
      public function reEdit():void
      {
         MyTween.labelTo(this, 'in');
      }

      /**
       * 結束編修照片
       */
      public function closePanel():void
      {
         MyTween.labelTo(this, 'stay', { onComplete:activeButton } );
      }

      // ------------------ LINE -------------------

      // ################ Protected ################

      // ################# Private #################

      private function onAdd(e:Event):void
      {
      }

      private function onRemove(e:Event):void
      {
         // tween
         MyTween.kill(this);
      }

      // ------------------ LINE -------------------

      // ------------------ LINE -------------------

      private function activeButton():void
      {
         btnEdit.onClick = function()
         {
            reEdit();
         }
      }

      // ------------------ LINE -------------------

   }

}